from abc import ABC, abstractmethod

class AIAssistant(ABC):
    """AI助手的抽象基类，包含所有AI助手的基本属性和方法"""
    
    def __init__(self, id, name, type, version, online, score):
        self._id = id
        self._name = name
        self._type = type
        self._version = version
        self._online = online
        self._score = score
        self._status_message = ""
    
    # Getter和Setter方法
    @property
    def id(self):
        return self._id
    
    @id.setter
    def id(self, id):
        self._id = id
    
    @property
    def name(self):
        return self._name
    
    @name.setter
    def name(self, name):
        self._name = name
    
    @property
    def type(self):
        return self._type
    
    @type.setter
    def type(self, type):
        self._type = type
    
    @property
    def version(self):
        return self._version
    
    @version.setter
    def version(self, version):
        self._version = version
    
    @property
    def online(self):
        return self._online
    
    @online.setter
    def online(self, online):
        self._online = online
    
    @property
    def score(self):
        return self._score
    
    @score.setter
    def score(self, score):
        self._score = score
    
    @property
    def status_message(self):
        return self._status_message
    
    @status_message.setter
    def status_message(self, status_message):
        self._status_message = status_message
    
    def start_service(self):
        """启动AI助手服务"""
        if not self._online:
            self._online = True
            print(f"✅ 助手【{self._name}】已启动。")
        else:
            print(f"助手【{self._name}】已在运行。")
    
    def stop_service(self):
        """停止AI助手服务"""
        if self._online:
            self._online = False
            print(f"✅ 助手【{self._name}】已停止。")
        else:
            print(f"助手【{self._name}】已经是停止状态。")
    
    def assign_task(self, task_content):
        """分配任务给AI助手"""
        if not self._online:
            print(f"❌ {self._name} 当前离线，无法执行任务。")
            return False
        return self.process_task(task_content)
    
    @abstractmethod
    def process_task(self, task_content):
        """处理任务的抽象方法，由子类实现"""
        pass
    
    def display_info(self):
        """显示助手的详细信息"""
        status = "🟢在线" if self._online else "🔴离线"
        print(f"✅ 查询结果: ID: {self._id}, 名称: {self._name}, 类型: {self._type}, 版本: {self._version}, 状态: {status}, 能力评分: {self._score} [{self._type}]")
    
    def display_brief_info(self, index):
        """显示助手的简略信息（用于列表显示）"""
        status = "在线" if self._online else "离线"
        print(f"{index}. ID: {self._id}, 名称: {self._name}, 类型: {self._type}, 版本: {self._version}, 状态: {status}, 能力评分: {self._score} [{self._type}]")